<?php
	require_once("../connectMysql/connetMysql.class.php");
	$actstype=array(1=>"分享会","研讨会","路演会","众筹会","观影会","悦读会","发布会","博览会","展销会","招聘会","交流会","培训会","充电会","其他");
	$actcharge=array(1=>"免费",10=>"10元",20=>"20元",30=>"30元",40=>"40元",50=>"50元",60=>"60元",100=>"100元",200=>"200元",300=>"300元",2=>"其他",3=>"AA"); 
	$db=new connetMysql;
	$con=$db->getConnect();
	$actId=$_GET['actId'];

	$chk_sql="SELECT * FROM activity WHERE ActivityId=".$actId;

	$get_aplyuser_namesql="SELECT UserName,OpenContact FROM actapply,user WHERE actapply.ActivityId = ".$actId." AND actapply.UserId = user.UserId";

	$result =mysqli_query($con,$chk_sql);
	$row = mysqli_fetch_assoc($result);	
	$get_user_namesql="SELECT UserName FROM `user` WHERE UserId='".$row["Userid"]."'";	
	$result2 =mysqli_query($con,$get_user_namesql);
	$row2 = mysqli_fetch_assoc($result2);
	$readNum=$row["ActRNum"]+1;
	$updateRN="UPDATE activity SET ActRNum=".$readNum." WHERE ActivityId=".$actId;
	$flag = 1;//0为app，1为web
	if(!isset($row['actTypea'])) 
	{
		$flag = 1;
	}
	else
	{
		$flag = 0;
	}

	$con->query($updateRN);
	if($flag==0)
	{
		$arr["a"] = array( 
		'actUserName' =>$row2["UserName"],
		'actDescri' => $row['ActDescri'], 
		'actStarta' => $row['actStarta'], 
		'actTypea' => $row['actTypea'],
		'actChargea' => $row['actChargea'], 
		'actLimitNuma' => $row['actLimitNuma'], 
		'ActAddress' => $row['ActAddress'],  
		'ActContent' => $row['ActContent']
		
 		 );
	}
	else
	{
		$arr["a"] = array( 
		'actUserName' =>$row2["UserName"],
		'actDescri' => $row['ActDescri'], 
		'actStarta' => date('Y-m-d',strtotime($row["ActStart"])), 
		'actTypea' => $actstype[$row["ActType"]],
		'actChargea' => $actcharge[$row["ActCharge"]], 
		'actLimitNuma' => $row["ActLimitNum"], 
		'ActAddress' => $row["ActProv"].$row["ActCity"].$row["ActAddress"],  
		'ActContent' => $row['ActContent']
		
 		 );
	} 

$result2=$con->query($get_aplyuser_namesql);
	while ($row2 = mysqli_fetch_assoc($result2))
	{
		$arr2[] = array(  
		'UserName'=>$row2['UserName'], 
		'OpenContact'=>$row2['OpenContact']
 		 ); 
	}
	$arr["b"] = $arr2;
	$con->close(); 
	echo json_encode($arr);
?>